package com.gc.business.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gc.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.gc.business.mapper.CustomerInfoMapper;
import com.gc.business.domain.CustomerInfo;
import com.gc.business.service.ICustomerInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;

/**
 * 客户 服务层实现
 * 
 * @author hruiyan
 * @date 2020-12-01
 */
@Slf4j
@Service
public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, CustomerInfo> implements ICustomerInfoService {

    @Override
    public List<CustomerInfo> list(CustomerInfo customerInfo){
        LambdaQueryWrapper<CustomerInfo> wrapper = new LambdaQueryWrapper<>();
        if(customerInfo != null){
            if(StringUtils.isNotEmpty(customerInfo.getCustomerId())){
                wrapper.eq(CustomerInfo::getCustomerId, customerInfo.getCustomerId());
            }
            if(StringUtils.isNotEmpty(customerInfo.getCompanyId())){
                wrapper.eq(CustomerInfo::getCompanyId, customerInfo.getCompanyId());
            }
            if(StringUtils.isNotEmpty(customerInfo.getHeadUserId())){
                wrapper.eq(CustomerInfo::getHeadUserId, customerInfo.getHeadUserId());
            }
            if(StringUtils.isNotEmpty(customerInfo.getCustomerName())){
                wrapper.like(CustomerInfo::getCustomerName, customerInfo.getCustomerName());
            }
            if(StringUtils.isNotEmpty(customerInfo.getSex())){
                wrapper.eq(CustomerInfo::getSex, customerInfo.getSex());
            }
            if(StringUtils.isNotEmpty(customerInfo.getCustomerCompany())){
                wrapper.like(CustomerInfo::getCustomerCompany, customerInfo.getCustomerCompany());
            }
            if(StringUtils.isNotEmpty(customerInfo.getPhoneNumber())){
                wrapper.eq(CustomerInfo::getPhoneNumber, customerInfo.getPhoneNumber());
            }
            if(StringUtils.isNotEmpty(customerInfo.getCreateBy())){
                wrapper.eq(CustomerInfo::getCreateBy, customerInfo.getCreateBy());
            }
            if(StringUtils.isNotEmpty(customerInfo.getCreateTime())){
                wrapper.eq(CustomerInfo::getCreateTime, customerInfo.getCreateTime());
            }
            if(StringUtils.isNotEmpty(customerInfo.getUpdateBy())){
                wrapper.eq(CustomerInfo::getUpdateBy, customerInfo.getUpdateBy());
            }
            if(StringUtils.isNotEmpty(customerInfo.getUpdateTime())){
                wrapper.eq(CustomerInfo::getUpdateTime, customerInfo.getUpdateTime());
            }
            if(StringUtils.isNotEmpty(customerInfo.getRemark())){
                wrapper.eq(CustomerInfo::getRemark, customerInfo.getRemark());
            }
        }
        return baseMapper.selectList(wrapper);
    }
}
